/*
 * Filename    : Scene_Menu.java
 * Projectname : SoiScene
 * Date        : Jan 3, 2013 , 12:20:12 PM 
 * 
 */

package id.pratama.soiscene.scene;

import id.pratama.soiscene.IManageableScene;
import id.pratama.soiscene.MainActivity;
import id.pratama.soiscene.SceneManager;
import id.pratama.soiscene.config.IApps_Data;
import id.pratama.soiscene.config.IApps_Define;

import org.andengine.entity.scene.IOnAreaTouchListener;
import org.andengine.entity.scene.ITouchArea;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.text.Text;
import org.andengine.input.touch.TouchEvent;
import org.andengine.ui.activity.BaseGameActivity;
import org.andengine.util.color.Color;

public class Scene_Menu extends Scene implements IManageableScene, IApps_Data, IApps_Define, IOnAreaTouchListener
{
	BaseGameActivity	activity;
	Text				txtStart;
	SceneManager		sm;

	public Scene_Menu(BaseGameActivity pActivity)
	{
		// TODO Auto-generated constructor stub
		activity = pActivity;
		sm = new SceneManager(activity);
		loadResources();
		applyResources();
		registerUpdateHandler();
	}

	@Override
	public void loadResources()
	{
		// TODO Auto-generated method stub
		txtStart = new Text(0, 0, MainActivity.mFont, "Start", activity.getVertexBufferObjectManager());
		setBackground(new Background(Color.WHITE));

	}

	@Override
	public void applyResources()

	{
		// TODO Auto-generated method stub
		attachChild(txtStart);
		txtStart.setPosition(RES_WIDTH / 2 - txtStart.getWidth() / 2, RES_HEIGHT / 2 - txtStart.getHeight() / 2);
		this.registerTouchArea(txtStart);

	}

	@Override
	public void registerUpdateHandler()
	{
		// TODO Auto-generated method stub
		this.setOnAreaTouchListener(this);

	}

	@Override
	public void unloadResources()
	{
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX,
			float pTouchAreaLocalY)
	{
		// TODO Auto-generated method stub
		if (pTouchArea.equals(txtStart))
		{
			sm.setScene(SceneManager.SCENE_ALATMUSIK);
		}
		return false;
	}

}
